<template>
  <div class="query-tool" @click="HeaderHooks.handleBarTitleClick('query')">查看工具</div>
  <div
    class="query-tool-list"
    :style="{ display: HeaderHooks.headerHooksData.queryVisibile ? 'flex' : 'none' }"
  >
    <div
      class="query-tool-list-item"
      v-for="t in queryBarList"
      :key="t.id"
      :class="t.isActive ? 'active' : ''"
    >
      <div @click="HeaderHooks.handleToolBarClick(t)">
        <a-trigger
          v-if="['transparency'].includes(t.code)"
          position="bl"
          trigger="click"
          class="query-tool-list-box"
          :popup-visible="t.isVisible"
          :unmount-on-close="false"
          :blur-to-close="false"
          :click-outside-to-close="false"
        >
          <div>
            <div class="icon-box">
              <i :class="`iconfont ${t.icon}`"></i>
            </div>
            <div class="label">{{ t.name }}</div>
          </div>
          <template #content>
            <div class="query-card">
              <div class="query-box-title">
                <div>{{ t.name }}</div>
                <div class="close-icon">
                  <icon-close @click="t.isVisible = false" />
                </div>
              </div>
              <div class="query-box-content">
                <div class="content-item">
                  <a-slider
                    show-input
                    :min="0"
                    :max="100"
                    v-model="HeaderHooks.headerHooksData.opacity"
                    @change="HeaderHooks.handleSliderChange(t, 'opacity', $event)"
                  />
                  <span class="item-suffix">%</span>
                </div>
              </div>
            </div>
          </template>
        </a-trigger>
        <div v-else>
          <div class="icon-box">
            <i :class="`iconfont ${t.icon}`"></i>
          </div>
          <div class="label">{{ t.name }}</div>
        </div>
      </div>
      <a-select
        v-model="HeaderHooks.headerHooksData.selectedCtWindow"
        placeholder="选择窗位"
        allow-clear
        popup-container=".select-down-list"
        @change="(e) => HeaderHooks.handleChangeWindow(e, t)"
        v-if="['windowAdjustment'].includes(t.code)"
      >
        <a-option
          v-for="ctWindow of FilmRead.interfaceData.windowList"
          :key="ctWindow.value"
          :value="ctWindow.value"
          :label="ctWindow.name"
        ></a-option>
      </a-select>
      <div class="select-down-list"></div>
    </div>
  </div>
</template>

<script lang="ts" setup name="QueryTool">
import * as Store from "@/store";

interface Prop {
  type: string;
  queryBarList: Header.QueryDataList[];
  HeaderHooks: Header.HeaderHooks;
}
const props = defineProps<Prop>();
const FilmRead = Store.useFilmRead();
</script>

<style lang="less" scoped>
@import url("../component.less");
</style>
<style lang="less">
.query-tool-list-box {
  padding: 1px;
  background-color: #353e44;
  border: 0;
  border-radius: 2px;
  .query-card {
    width: 230px;
    height: 48px;
    background: #42484c;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.5);
    border-radius: 2px;
    padding-bottom: 3px;
    .query-box-title {
      height: 24px;
      display: flex;
      justify-content: space-between;
      border-bottom: 1px solid #5c6871;
      user-select: none;
      align-items: center;
      padding: 0 6px;
      color: #fff;
      font-weight: 400;
      font-size: 12px;
      line-height: 12px;
    }
    .close-icon {
      cursor: pointer;
    }
    .query-box-content {
      padding: 0 6px;
      .content-item {
        margin-top: 6px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        font-weight: 400;
        font-size: 12px;
        line-height: 12px;
        color: #fff;
        .item-title {
          white-space: nowrap;
          margin-right: 8px;
        }
        .item-suffix {
          display: inline-block;
          width: 11px;
          height: 12px;
          margin-left: 2px;
        }
        .arco-slider {
          flex: 1;
        }
        .arco-slider-input {
          margin-left: 6px;
          .arco-input-wrapper {
            width: 38px;
            height: 18px;
            background-color: transparent;
            border: 1px solid #ccc;
            color: #fff;
            padding: 0;
          }
        }
      }
    }
  }
}
</style>
